def max_profit(prices):
    if not prices:
        return 0
    min_price = prices[0]
    max_profit_ = 0
    for price in prices:
        min_price = min(min_price, price)
        max_profit_ = max(max_profit_, price - min_price)
    return max_profit_

# 找到列表中最小值和最大值进行减法运算
prices = [1, 5, 3, 6, 4, 7, 10]
print(max_profit(prices))
